<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>play audio</button>
    <audio src="../02－Spare That Spider.mp3" controls></audio>
    <script>
        var audio = document.querySelector('audio')
        var button = document.querySelector('button')
        var times = 0, sTime = 0
        audio.ontimeupdate = function () {
            if (times < 3) {
                if (audio.currentTime >= sTime + 5) {
                    audio.currentTime = sTime
                    times++
                }
            } else {
                times = 0
                sTime += 5
            }
        }
        button.addEventListener('click', function () {
            audio.play()
        })
    </script>
</body>
</html>